package com.heima.user.controller.v1;

import com.heima.common.constants.admin.AdminConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDTO;
import com.heima.user.service.ApUserRealnameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "app用户实名认证API",tags = "app用户实名认证API")
@RestController
@RequestMapping("/api/v1/auth")
public class UserController {

    //依赖注入
    @Autowired
    private ApUserRealnameService apUserRealnameService;

    @ApiModelProperty("根据状态查询实名认证列表")
    @PostMapping("/list")
    public ResponseResult findByStatus(@RequestBody AuthDTO authDTO){
        return apUserRealnameService.loadListByStatus(authDTO);
    }

    /**
     * 用户审核通过
     * @param authDTO
     * @return
     */
    @ApiModelProperty("用户审核通过")
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDTO authDTO){
        return apUserRealnameService.updateStatusById(authDTO, AdminConstants.PASS_AUTH);
    }

    /**
     * 用户审核不通过
     * @param authDTO
     * @return
     */
    @ApiModelProperty("用户审核不通过")
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDTO authDTO){
        return apUserRealnameService.updateStatusById(authDTO,AdminConstants.FAIL_AUTH);
    }
}
